package se.webbzon.boltzmann.game.sequence;

import se.webbzon.boltzmann.game.object.dialogue.AbstractDialogue;
import se.webbzon.boltzmann.game.object.dialogue.ItemDialogue;
import se.webbzon.boltzmann.game.object.dialogue.ItemDialogueListener;
import se.webbzon.boltzmann.item.AbstractItem;

public class ItemDialogueSequenceNode extends AbstractDialogueSequenceNode implements ItemDialogueListener {
	
	// The next sequence node
	private SequenceNode branch;
	
	/*============================================================
	Public Methods
	============================================================*/

	public ItemDialogueSequenceNode(Sequence sequence, ItemDialogue dialogue) {
		super(sequence, dialogue);
		dialogue.addListener(this);
	}
	
	/*============================================================
	Public Methods
	============================================================*/
	
	/** Sets the next sequence node related to this simple dialogue 
	 * sequence node. If this node is a leaf then the next node 
	 * should be null. **/
	public void setBranch(SequenceNode branch) {
		this.branch = branch;
	}

	@Override public int branches() {
		return (branch == null) ? 0 : 1;
	}

	@Override public SequenceNode getBranch(int n) {
		return branch;
	}
	
	/*============================================================
	Protected Methods
	============================================================*/
	
	@Override public void onShowInput(AbstractDialogue dialogue) {};

	@Override public void onContinue(ItemDialogue dialogue, AbstractItem item) {
		getSequence().next(0);
	}

}
